    function stop = pigraph(optimValues,state)
% this functions graphs beliefs at each iteration of the optimisation
stop = false; % This function does not stop the solver

        setup_states;
 
        % belief coeficients
        beliefparms.theta=optimValues.bestx(3:9);
        beliefparms.gamma=optimValues.bestx(10);
        beliefparms.gamma_mod=optimValues.bestx(2);
          
         fixedparms.ind_goodgirl=1;
         pi = makepi(states,fixedparms,beliefparms);
         fixedparms.ind_goodgirl=0;
         pi_bad = makepi(states,fixedparms,beliefparms);
                 
         for e = 7:13
     f = find(states(:,2)==e);
     plot(states(f, 1), pi(f, 2));
     hold on
         end

         for e = 7:13
     f = find(states(:,2)==e);
     plot(states(f, 1), pi_bad(f, 2),'--');
     hold on
         end

     a=13:22;
    title(optimValues.bestx)
    set(gca, 'FontSize', 12)
    xlabel("Age", 'FontSize', 14)
    ylabel("Probability of High Offer", 'FontSize', 14)
    axis([12 22 0 0.5])
    legend("Grade 7","Grade 8","Grade 9","Grade 10","Grade 11", ...
                "Grade 12","College","Sigma/10" ,'Location','northwest')
    hold off
    
    drawnow
    
    
    end